/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg.data;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.primefaces.model.DefaultScheduleEvent;

/**
 *
 * @author Shengyi_Chen
 */
public class ClassCalSchEvent extends DefaultScheduleEvent{
    
    private String id;
    private String title;
    private String startDateOnly;
    private Date startTime;
    private Date theDayBeforeStartDate;
    private Date startDate;
    private Date endDate;
    private Date oneMonthLater;
    private boolean allDay;
    private String styleClass;
    private Object data;
    private boolean editable;
    private int studentNumber;

    public ClassCalSchEvent() {
    }

    public ClassCalSchEvent(String title, Date startDate, Date endDate) {
        this.title = title;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public ClassCalSchEvent(String title, Date startDate, Date endDate, boolean allDay) {
        this.title = title;
        this.startDate = startDate;
        this.endDate = endDate;
        this.allDay = allDay;
    }
    
    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void setId(String string) {
        this.id = string;
    }

    @Override
    public Object getData() {
        return this.data;
    }

    @Override
    public String getTitle() {
        return this.title;
    }

    @Override
    public Date getStartDate() {
        return this.startDate;
    }

    @Override
    public Date getEndDate() {
        return this.endDate;
    }

    @Override
    public boolean isAllDay() {
        return this.allDay;
    }

    @Override
    public String getStyleClass() {
        return this.styleClass;
    }

    @Override
    public boolean isEditable() {
        return this.editable;
    }

    /**
     * @return the oneMonthLater
     */
    public Date getOneMonthLater() {
        return oneMonthLater;
    }

    /**
     * @param oneMonthLater the oneMonthLater to set
     */
    public void setOneMonthLater(Date oneMonthLater) {
        this.oneMonthLater = oneMonthLater;
    }

    /**
     * @return the studentNumber
     */
    public int getStudentNumber() {
        return studentNumber;
    }

    /**
     * @param studentNumber the studentNumber to set
     */
    public void setStudentNumber(int studentNumber) {
        this.studentNumber = studentNumber;
    }

    /**
     * @param title the title to set
     */
    @Override
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @param startDate the startDate to set
     */
    @Override
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    /**
     * @param endDate the endDate to set
     */
/*    public void setEndDate(Date endDate) {
        Calendar cD = Calendar.getInstance();
        cD.setTime(endDate);
        cD.add(Calendar.DAY_OF_YEAR, 1);
        this.endDate = cD.getTime();
    }
*/
    
    /**
     * @param allDay the allDay to set
     */
    @Override
    public void setAllDay(boolean allDay) {
        this.allDay = allDay;
    }

    /**
     * @param styleClass the styleClass to set
     */
    @Override
    public void setStyleClass(String styleClass) {
        this.styleClass = styleClass;
    }

    /**
     * @param data the data to set
     */
    @Override
    public void setData(Object data) {
        this.data = data;
    }

    /**
     * @param editable the editable to set
     */
    @Override
    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    /**
     * @return the theDayBeforeStartDate
     */
    public Date getTheDayBeforeStartDate() {
        Calendar rightNow = Calendar.getInstance();
        if (startDate != null){
        rightNow.setTime(startDate);
        }
        rightNow.add(Calendar.DAY_OF_YEAR, -1);
        theDayBeforeStartDate = rightNow.getTime();
        return theDayBeforeStartDate;
    }

    /**
     * @param theDayBeforeStartDate the theDayBeforeStartDate to set
     */
    public void setTheDayBeforeStartDate(Date theDayBeforeStartDate) {
        this.theDayBeforeStartDate = theDayBeforeStartDate;
    }

    /**
     * @return the startDateOnly
     */
    public String getStartDateOnly() {
        SimpleDateFormat dateToStr = new SimpleDateFormat ("MMM dd, yyyy");
        if (startDate != null){
            startDateOnly = dateToStr.format(startDate);
        }else{
            Calendar today = Calendar.getInstance();
            startDateOnly = dateToStr.format(today.getTime());
        }
        return startDateOnly;
    }

    /**
     * @param startDateOnly the startDateOnly to set
     */
    public void setStartDateOnly(String startDateOnly) {
        
        this.startDateOnly = startDateOnly;
    }

    /**
     * @return the startTime
     */
    public Date getStartTime() {
        if (startTime == null){
            startTime = startDate;
        }
        return startTime;
    }

    /**
     * @param startTime the startTime to set
     */
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    
}
